# import random
# class Player:
#     def __init__(self):
#         self.dict = {0: '剪刀', 1: '石头', 2: '布'}
# # 手势
#     def gesture(self):
#         player_input = int(input("请输入(0剪刀、1石头、2布:)"))
#         return self.dict[player_input]
# class AIPlayer(Player):
#         play_data = []
#         def ai_gesture(self):
#             while True:
#                 computer = random.randint(0, 2)
#                 if len(self.play_data) >= 4:
#             # 获取玩家出拳的最大概率
#                     max_prob = max(self.play_data, key=self.play_data.count)
#                 if max_prob == '剪刀':
#                     return '石头'
#                 elif max_prob == '石头':
#                     return '布'
#                 else:
#                     return '剪刀'
#             else:
#                 return self.dict[computer]
# class Game:
#     def game_judge(self):
#         player = Player().gesture()
#         AIPlayer().play_data.append(player)
#         aiplayer = AIPlayer().ai_gesture()
#     if(player == '剪刀' and aiplayer == '布') or (player == '石头' and aiplayer == '剪刀') or (player == '布' and aiplayer == '石头'):
#         print(f"电脑出的手势是{aiplayer},恭喜，你赢了！")
#     elif(player == '剪刀' and aiplayer == '剪刀') or (player == '石头' and aiplayer == '石头') or (player == '布' and aiplayer == '布'):
#         print(f"电脑出的手势是{aiplayer},打成平局了！")
#     else:
#         print(f"电脑出的手势是{aiplayer},你输了，再接再厉！")
#     def game_start(self):
#         self.game_judge()
#         while True:
#             option = input("是否继续：y/n\n")
#             if option == 'y':
#                 self.game_judge()
#             else:
#                 break
# if __name__ == '__mian__':
#     g = Game()
#     g.game_start()

import  random


# 玩家类
class Player:
    # 构造玩家函数
    def __init__(self, NUM_Custom): # 通过有（形）参构造的方式使得对象属性能够拥有不同的初始值
        self.Name = '玩家'
        self.NUM_Custom = NUM_Custom # 将形参赋值给属性
    # 实例方法定义一个输出玩家出拳方式的函数
    def Gesture_Custom(self):
        if self.NUM_Custom == 1:
            print(f'{self.Name}出拳方式为：[石头]')
        elif self.NUM_Custom == 2:
            print(f'{self.Name}出拳方式为：[剪刀]')
        elif self.NUM_Custom == 3:
            print(f'{self.Name}出拳方式为： [布] ')


# 人机类
class Computer:
    # 构造人机函数
    def __init__(self, NUM_Random):
        self.Name = '人机'
        self.NUM_Random = NUM_Random
    # 实例方法定义一个获取人机出拳方式的函数
    def Gesture_Random(self):
        if self.NUM_Random == 1:
            print(f'{self.Name}出拳方式为：[石头]')
        elif self.NUM_Random == 2:
            print(f'{self.Name}出拳方式为：[剪刀]')
        elif self.NUM_Random == 3:
            print(f'{self.Name}出拳方式为： [布] ')


# 游戏类
class Game:
    print('请按对应编号选择您的出拳方式：\n1 [石头]\n2 [剪刀]\n3  [布]\n4 退出游戏\n'+'-' * 30)
    # 静态方法定义一个运行游戏的函数
    def Run(self):
        while True:
            # 由于使用了实例方法，只能通过对象来调用而无法通过类直接调用
            NUM_Custom = int(input('请选择您的出拳方式:')) # 创建实参
            person = Player(NUM_Custom) # 创建对象，并根据实参初始化属性
            person.Gesture_Custom() # 通过对象调用实例方法
            #
            NUM_Random = random.randint(1, 3)
            computer = Computer(NUM_Random)
            computer.Gesture_Random()
            #
            if NUM_Custom == 1:
                if NUM_Random == 1:
                    print('本局平局')
                elif NUM_Random == 2:
                    print('本局玩家获胜')
                elif NUM_Random == 3:
                    print('本局电脑获胜')
            elif NUM_Custom == 2:
                if NUM_Random == 1:
                    print('本局电脑获胜')
                elif NUM_Random == 2:
                    print('本局平局')
                elif NUM_Random == 3:
                    print('本局玩家获胜')
            elif NUM_Custom == 3:
                if NUM_Random == 1:
                    print('本局玩家获胜')
                elif NUM_Random == 2:
                    print('本局电脑获胜')
                elif NUM_Random == 3:
                    print('本局平局')
            elif NUM_Custom == 4:
                print('游戏结束')
                break
            else:
                print('输入有误！')

            print('-' * 30)


# 调用游戏类
Game.Run() # 由于使用静态方法，可以通过类直接调用